
<meta charset="utf-8">

<div class="box" id="biz_mettings_conatainer">
	<div class="box-header with-border">
		<form id="searchForm" role="form" class="form-inline">
			<div class="form-group">
				<label for="title" >会议名称</label> 
				<input name="title" v-model="searchForm.title" type="text" placeholder="" class="form-control">
			</div>
			<div class="form-group">
				<label for="status" > 会议状态</label><!-- 1报名中，2报名结束，3会议进行中，4会议结束，5取消-1移除 # -->
				<select  class="form-control" id="status" name="status"  v-model="searchForm.status">
					<option value="1">报名中</option>
					<option value="2">报名结束</option>
					<option value="3">会议进行中</option>
					<option value="4">会议结束</option>
					<option value="5">会议取消</option>
				</select>
			</div>
			<button type="button" class="btn btn-info pull-right m-t-n-xs" v-on:click="search">
				<strong>查询</strong>
			</button>
		</form>
	</div>
	<div class="box-body">
		<div class="row">
			<div class="col-md-12">
				<div class="btn-group " id="mettingsTableToolbar" role="group">
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="add">
						<i class="glyphicon glyphicon-plus" aria-hidden="true"></i> 创建新活动
					</button>

					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="edit">
						<i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> 修改活动
					</button>
					
					
					
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="setStatus(1)">
						<i class="glyphicon glyphicon-user" aria-hidden="true"></i> 开启报名
					</button>
					
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="setStatus(2)">
						<i class="glyphicon glyphicon-user" aria-hidden="true"></i> 结束报名
					</button>
					
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="setStatus(3)">
						<i class="glyphicon glyphicon-user" aria-hidden="true"></i> 开启活动
					</button>
					
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="setStatus(4)">
						<i class="glyphicon glyphicon-user" aria-hidden="true"></i> 结束活动
					</button>
					
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="setStatus(5)">
						<i class="glyphicon glyphicon-trash" aria-hidden="true"></i> 取消活动
					</button>
					<button type="button" v-kperms="{perm:''}" class="btn btn-default" v-on:click="setStatus(-1)">
						<i class="glyphicon glyphicon-trash" aria-hidden="true"></i> 删除活动
					</button>
					
					
				</div>
				<table id="mettingsBootstrapTable" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
</div>
<script>

    
var mettings_list_main=new Vue({  
	  el: '#biz_mettings_conatainer',
	  data:{
		  searchForm:{
			  title: null,
			  status: null
		 },
		  bus:new Vue(),
	  },
	  mounted:function(){
		  var _this=this;
		_this.initTable();
	  },
    methods: {
  	  initTable:function(){
  		var _this=this;
  		  var columns=[
  					{checkbox:true,width:20},
  					{field:'title',title:'会议标题',width:200},
  					{field:'metStartTime',title:'会议开始时间',width:40,formatter:function(value, row, index){return value.substring(0,10)}},
                    {field:'metEndTime',title:'会议结束时间',width:40,formatter:function(value, row, index){return value.substring(0,10)}},
                    {field:'signupStartTime',title:'报名开始时间',width:40,formatter:function(value, row, index){return value.substring(0,10)}},
                    {field:'signupEndTime',title:'报名结束时间',width:40,formatter:function(value, row, index){return value.substring(0,10)}},
					{field:'signupCount',title:'报名人数',width:40,formatter:_this.formatSignup},
					{field:'createTime',title:'创建时间',width:40,formatter:function(value, row, index){return value.substring(0,10)}},
					{field:'status',title:'当前状态',width:40,formatter:MetFormat.formatMettingsStatus},
					{field:'',title:'操作',width:110,formatter:_this.formatEntry}]; 
  		  var url="/met/service/tenant/mettings/loadMettingsDataSet";
    		zfesBstable.laodTable($("#mettingsBootstrapTable"),$("#searchForm"),$("#mettingsTableToolbar"),url,columns,this.searchForm);
  	  },
  	  search:function(){
  		  zfesBstable.reload($("#mettingsBootstrapTable")); 
  	  },
  	  refresh:function(){
  		  zfesBstable.refresh($("#mettingsBootstrapTable"));
  	  },
  	  add:function(){
  		  var　_this=this;
  		 var url="/views/tenant/mettings/mettings.add.html";
  		 zfesLayerEditDg.open(url,{},"创建会议",960,function(){_this.refresh();});
  		 
  	  },
  	  edit:function(){
  		  if(zfesBstable.isOneRow($("#mettingsBootstrapTable"))){
  			  var　_this=this;
  			  var id=zfesBstable.getRowId($("#mettingsBootstrapTable"));
  			  var url="/views/tenant/mettings/mettings.edit.html";
  			  zfesLayerEditDg.open(url,{"id":id},"项目信息编辑",960,function(){_this.refresh();}); 
  		 }
  	  },

  	deleteMettings: function(){
  		if(zfesBstable.isSelectedRow($("#mettingsBootstrapTable"))){
			  var　_this=this;
			    var id=zfesBstable.getRowId($("#mettingsBootstrapTable"));
				 alertSwal.confirm("删除","是否删除该项目",function(){
					    var ajaxUrl = "/met/service/tenant/mettings/deleteMettings";
						zfesAjax.ajaxTodo(ajaxUrl, { "id" : id,"status":-1}, function(data) {
							alertSwal.successText(data.message);
							_this.refresh();
						}); 
			});
		}
 	  },
 	  setStatus: function(status){
 		 if(zfesBstable.isSelectedRow($("#mettingsBootstrapTable"))){
			  var　_this=this;
			    var id=zfesBstable.getRowId($("#mettingsBootstrapTable"));
				 alertSwal.confirm("删除","是否删除该项目",function(){
						 var ajaxUrl="";//#0待发布，1报名中，2报名结束，3会议进行中，4会议结束，5取消-1移除 #
						 if(1==status){
							 ajaxUrl = "/met/service/tenant/mettings/startSignup";
						 }else if(2==status){
							 ajaxUrl = "/met/service/tenant/mettings/endSignup";
						 }else if(3==status){
							 ajaxUrl = "/met/service/tenant/mettings/startMettings";
						 }else if(4==status){
							 ajaxUrl = "/met/service/tenant/mettings/endMettings";
						 }else if(5==status){
							 ajaxUrl = "/met/service/tenant/mettings/cancelMettings";
						 }else if(-1==status){
							 ajaxUrl = "/met/service/tenant/mettings/deleteMettings";
						 }
						zfesAjax.ajaxTodo(ajaxUrl, { "id" : id}, function(data) {
							alertSwal.successText(data.message);
							_this.refresh();
						}); 
			});
		}
 	  },
 	  	formatEntry: function(value, row, index){
 	  		var _this=this;
 	  		return '<a href="javascript:void(0)"><span  class="label label-success" onClick="entrySignupTemplate('+row.id+')">报名模板</span></a>        '
 	  		+'<a href="javascript:void(0)"><span  class="label label-info" onClick="entrySigninPage('+row.id+')">签到信息</span></a>';
 	  	},
 	  	entrySignupTemplate: function(id){
 	  		var url="/views/tenant/signup/signup.template.html#metId="+id+"";
 	  		zfesRoutie.load(url,"报名模板");
 	  	},
 	  	entrySignupPage: function(metId){
 	  		var url="/views/tenant/signup/signup.html#metId="+metId+"";
 	  		zfesRoutie.load(url,"报名信息");
 	  	},
 	  	formatSignup: function(value, row, index){
 	  		var _this=this;
 	  		return '<a href="javascript:void(0)"><span  class="label label-danger" onClick="entrySignupPage('+row.id+')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+value+'&nbsp;人&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></a> ';
 	  		
 	  	}
   	
   }
});

function entrySignupTemplate(id){
	mettings_list_main.entrySignupTemplate(id);
}
function entrySigninPage(id){
	mettings_list_main.entrySignupTemplate(id);
}
function entrySignupPage(metId){
	mettings_list_main.entrySignupPage(metId);
}

</script>


